package com.adms.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.adms.domain.Reform;
import com.adms.service.ReformService;

@RequestMapping("reform")
@RestController
public class ReformController {

	@Autowired
	private ReformService reformService;
	
	@GetMapping("{reformId}")
	public Object getByReformId(@PathVariable("reformId") Integer reformId) {
		return reformService.getByReformId(reformId);
	}
	
	@GetMapping("getWithCustom")
	public Object getByReformIdWithCustom(@RequestParam("reformId") Integer reformId) {
		return reformService.getByReformIdWithCustom(reformId);
	}
	
	@GetMapping
	public Object list(Reform reform,Boolean isSelf,String timeField,Date start,Date end,String key,String orderByClause,
			@RequestParam(defaultValue = "1") Integer pageNum,
			@RequestParam(defaultValue = "5") Integer pageSize,
			@RequestParam(defaultValue = "5") Integer navigatePages) {
		return reformService.list(reform,isSelf,timeField,start,end,key,orderByClause,pageNum,pageSize,navigatePages);
	}
	
	@GetMapping("listRelative")
	public Object listRelative(@RequestParam("reformId") Integer reformId,@RequestParam("type") Integer type,Integer state,Integer signType) {
		return reformService.listRelative(reformId,type,state,signType);
	}
	
	@GetMapping("count")
	public Object count() {
		return reformService.count();
	}
	
	@PostMapping("publish")
	public Object publish(Reform reform) {
		return reformService.publish(reform);
	}
	
	@PostMapping("continue")
	public Object continuePublish(Reform reform) {
		return reformService.continuePublish(reform);
	}

	@PostMapping("respond")
	public Object respond(@RequestParam("reformId") Integer reformId,String content,String signature) {
		return reformService.respond(reformId,content,signature);
	}
	
	@PostMapping("defer")
	public Object defer(@RequestParam("reformId") Integer reformId,String content,String images,Date delayTime) {
		return reformService.defer(reformId,content,images,delayTime);
	}
	
	@PostMapping("handle")
	public Object handle(@RequestParam("reformId") Integer reformId,String content,String images) {
		return reformService.handle(reformId,content,images);
	}
	
	@PostMapping("inspect")
	public Object inspect(@RequestParam("reformId") Integer reformId,String content,String images) {
		return reformService.inspect(reformId,content,images);
	}
	
	@PostMapping("confirm")
	public Object confirm(@RequestParam("reformId") Integer reformId,String images) {
		return reformService.confirm(reformId,images);
	}
	
	@PostMapping("update")
	public Object update(Reform reform) {
		return reformService.update(reform);
	}

	@PostMapping("delete")
	public Object delete(@RequestParam("reformIds") int[] reformIds) {
		return reformService.delete(reformIds);
	}
	
	@PostMapping("transferTo")
	public Object transferTo(@RequestParam("reformId") Integer reformId,@RequestParam("userId") Integer userId) {
		return reformService.transferTo(reformId,userId);
	}
}
